package com.ljh.service.impl;

import com.ljh.entity.Student;
import com.ljh.mapper.UserMapper;
import com.ljh.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author grung
 * @Date 2021/3/8 16:26
 * @Version 1.0
 */

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public String saveStudent(Student student) {
        int i = this.userMapper.insert(student);
        if (i>0){
            return "save success";
        }
        return "save fail";
    }

    @Override
    public String deleteStudent(Integer id) {
        int i = this.userMapper.deleteById(id);
        if (i>0){
            return "delete success";
        }
        return "delete fail";
    }

    @Override
    public String updateStudent(Student student) {
        int i = this.userMapper.update(student, null);
        if (i>0){
            return "update success";
        }
        return "update fail";
    }

    @Override
    public Student selectStudent(Integer id) {
        Student student = this.userMapper.selectById(id);
        return student;
    }
}
